package McSatan;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Connection;

public class SearchResult {
	Connection con;
	String searchString, foodType, priceRange, offers;
	String[] ingredients = new String[8];
	ResultSet rs;
	
	
	public SearchResult(String searchString, String foodType, String priceRange, String offers){
		System.out.println(searchString);	
		try{ 
			Class.forName("com.mysql.jdbc.Driver");
		}catch(ClassNotFoundException e){
			System.out.println("ERror : " + e);
		}
		try{
			con = DriverManager.getConnection("jdbc:mysql://localhost:3306/", "McSatan", "aftermath69");
			System.out.println("funnkar");
		}catch(Exception e){
			System.out.println(e);
		}
		try{
		Statement stmt = (Statement) con.createStatement();
		
		String query = "SELECT distinct menu.rest_id, menu.dish, menu.description " +
				"FROM dss_1.menu AS menu" +
				" WHERE menu.dish like '%" + searchString + "%'" +
				"OR menu.description like '%" + searchString + "%'" + 
				"ORDER BY menu.rest_id";
		
		rs = stmt.executeQuery(query);
		}catch(Exception e){
			System.out.println(e);
		}
		
		this.searchString = searchString;
		this.foodType = foodType;
		this.priceRange = priceRange;
		this.offers = offers;
	}
	
	

	public ResultSet getResultSet(){
		return rs;
	}
	public String[] getIngredients() {
		return ingredients;
	}

	public void setIngredients(String[] ingredients) {
		this.ingredients = ingredients;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	public String getFoodType() {
		return foodType;
	}

	public void setFoodType(String foodType) {
		this.foodType = foodType;
	}

	public String getPriceRange() {
		return priceRange;
	}

	public void setPriceRange(String priceRange) {
		this.priceRange = priceRange;
	}

	public String getOffers() {
		return offers;
	}

	public void setOffers(String offers) {
		this.offers = offers;
	}
}